package com.ruoyi.resume.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.resume.domain.request.LabelingRequest;
import com.ruoyi.resume.service.CustomLabelingService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "标签识别与存储")
@RestController
@RequestMapping("/custom")
public class CustomLabelingController {

    @Autowired
    private CustomLabelingService customLabelingService;

    /**
     * 根据用户自定义标签描述进行打标签
     * @param request 结构化简历数据及标签信息
     * @return 自定义标签的ID和对应数量列表
     */
    @ApiOperation("根据用户自定义标签描述进行打标签")
    @ApiImplicitParam(
            name = "request",
            value = "结构化简历数据及分类信息",
            required = true,
            dataType = "LabelingRequest",
            paramType = "body"
    )
    @PostMapping("/labeling")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> saveResume(@RequestBody LabelingRequest request) {
        // 调用服务层生成自定义标签
        List<Map<String, Integer>> labels = customLabelingService.generateCustomLabels(request);
        return ResponseEntity.ok(labels);
    }

}
